<?php
namespace app\admin\controller;

use think\Controller;
use think\Request;
use app\common\lib\Upload;


/**
 * 后台图片上传相关逻辑
 * Class Image
 * @package app\admin\controller
 */
class Qiniu extends Controller{
    /**
     * 七牛图片上传
     */
    public function upload() {
        try {
            $image = Upload::image();
        }catch (\Exception $e) {
            echo json_encode(['status' => 0, 'message' => $e->getMessage()]);
            exit;
        }
        if($image) {
            $data = [
                'status' => 1,
                'message' => 'OK',
                'data' => config('qiniu.cdn_domain').'/'.$image,
            ];
            echo json_encode($data);exit;
        }else {
            echo json_encode(['status' => 0, 'message' => '上传失败']);
        }
    }
}
